package io.gitee.skyarthur1987.leporidae.delayqueue.autoconfigure;

import io.gitee.skyarthur1987.leporidae.delayqueue.api.DelayQueue;
import io.gitee.skyarthur1987.leporidae.delayqueue.core.ZSetDelayQueue;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * Created by skyarthur on 2023/1/27
 */
@Configuration
@ConditionalOnProperty(name = "leporidae.delay-queue.enable", havingValue = "true")
@Import(value = {
        DelayQueueConsumerConfig.class,
        DelayQueuePollEventAsyncConfig.class
})
public class DelayQueueAutoConfiguration {

    @Bean
    public DelayQueue<String> zSetDelayQueue(StringRedisTemplate stringRedisTemplate) {
        return new ZSetDelayQueue(stringRedisTemplate);
    }
}
